package com.qzy.reggie.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qzy.reggie.common.PageResult;
import com.qzy.reggie.mapper.LppCategoryMapper;
import com.qzy.reggie.mapper.LppEmployeeMapper;
import com.qzy.reggie.pojo.Category;
import com.qzy.reggie.pojo.Employee;
import com.qzy.reggie.service.LppCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LppCategoryServiceImpl implements LppCategoryService {

    @Autowired
    private LppCategoryMapper lppCategoryMapper;


    @Override
    public PageResult queryCategoryList(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);

        List<Employee> categorys = lppCategoryMapper.selectList();

        PageInfo<Employee> pageInfo = new PageInfo<>(categorys);


        return new PageResult(pageInfo.getTotal(),categorys);
    }

    @Override
    public Category getCategoryById(Long id) {
        if(id == null){
            return null;
        }
        Category category = new Category();
        category.setId(id);
        return lppCategoryMapper.selectOne(category);
    }


    @Override
    public Integer save(Category category) {

        return lppCategoryMapper.insert(category);
    }

    @Override
    public Integer update(Category category) {
        return lppCategoryMapper.update(category);
    }

}
